<?php

namespace app\common\model;

use think\Model;

class Articles extends Model
{
    //添加文章
    public function addArticles($data){
        $validate = new \app\common\validate\Articles();
        if (!$validate->scene('add')->check($data)){
            return $validate->getError();
        }
        $result = $this->allowField(true)->save($data);
        if ($result){
            return 1;
        }else{
            return '添加文章失败';
        }

    }
    //删除文章
    public function deleteArticles(){

    }
    //修改文章
    public function updateArticles($id,$data){
        $validate = new \app\common\validate\Articles();
        if (!$validate->scene('add')->check($data)){
            return $validate->getError();
        }
        $result = $this->where('id',$id)->update($data);
        if ($result){
            return 1;
        }else{
            return '修改失败';
        }

    }
    //文章列表
    public function listeArticles(){

    }
    //文章详情
    public function contentArticles(){

    }
}
